/**
	Constructs a 

	@author Francis Villanueva
	@version 2006-10-19
	@copyright (c) 2006 The Chopping Block, Inc. All rights reserved.

	@usage

	- Activate with:
	<code>

	</code>

*/

class VideoPlayerModel {
	
// ===========================================================
// - VARIABLES
// ===========================================================

	//video title
	private var title:String;
	private var playlistData:Object;
	private var videoCount:Number;
	private var filteredData:Object;
	private var filteredVideoCount:Number;
	
// ===========================================================
// - ACCESSORS
// ===========================================================

	//public function getTitle ()				{ return title };
	
	public function getVideos () { return playlistData };
	
	public function	getFilteredVideos() { return filteredData };
	
	public function setFilteredVideos(videos:Array) {
		trace("MDL setFilteredVideos"); 
		this.filteredData = videos;
		this.filteredVideoCount = videos.length;
	};
// ===========================================================
// - CONSTRUCTOR 
// ===========================================================
	function VideoPlayerModel(){
		trace("MDL VideoPlayerModel");
	};
	
// ===========================================================
// - FUNCTIONS
// ===========================================================

	function init(data:Object){
		trace("MDL init");
		this.playlistData = data;
		this.videoCount = this.playlistData.playlist.video.length;
	};
		
	function getVideo(index:Number):Object{
		trace("MDL getVideo");
		var currVideo = filteredData[index];
		return currVideo;
	};
	
	function getVideoByID(id:String):Object {
		trace("MDL getVideoByID");
		for(var i=0;i<this.filteredVideoCount;i++) {
			var currVideo = filteredData[i];
			if(currVideo.id._value == id) {
				trace("FOUND VIDEO BY ID OF: "+id)
				currVideo.index = i;
				return currVideo;
			}
		}
		trace("\t -----------> NO VIDEO FOUND BY THAT ID");
		var currVideo = filteredData[0];
		currVideo.index = 0;
		return currVideo;
	}
	
	
}